Imports System.Collections.Generic


' species abundance for non-spatial data
Public Interface IAbundanceCollection
    Sub AddAbundance(ByVal UniqueKey As String, ByVal AbundanceValue As Double)
    ReadOnly Property Count() As Integer
    ReadOnly Property AbundanceByUniqueKey(ByVal Key As String) As Double
    ReadOnly Property AbundanceByIndexBaseOne(ByVal Index As Integer) As Double
End Interface

' Value 0 means automatic rejection when filtering
' Value 1 means automatic inclusion when filtering
' Value between 0..1 is inclusion probability when filtering
' all kinds of logic can be built upon this foundation!
Public Interface IListFilterItem
    ReadOnly Property UniqueKey() As String
    ReadOnly Property Value() As Double
End Interface


' this is initially the "sampled plots" but when filtering is some subset OR custom list filter
' Note that order of items does not need to match the order the tree was constructed
Public Interface IListFilter
    ReadOnly Property Name() As String
    ReadOnly Property Count() As Integer
    ReadOnly Property ListFilterItemByIndexBaseOne(ByVal Index As Integer) As IListFilterItem
    ReadOnly Property ListFilterItemByUniqueName(ByVal Name As String) As IListFilterItem
    Function AddListFilterItem(ByVal UniqueKey As String, ByVal Value As Double) As IListFilterItem
End Interface


' concrete class must also implement IComparable
Public Interface INeighbourhoodPlant
    ReadOnly Property Plant() As IPlant
    ReadOnly Property SpatialDistanceFromCenterPlant() As Double
    ReadOnly Property TaxonomicDistanceFromCenterPlant() As Single
End Interface


Public Interface INeighbourhood
    ReadOnly Property CenterPlant() As IPlant
    ReadOnly Property CountOfNeighbours() As Integer
    ReadOnly Property NeighbourhoodPlantByIndexBaseOne(ByVal Index As Integer) As INeighbourhoodPlant
    Sub AddNeighbourhoodPlant(ByVal NeighbourhoodPlant As INeighbourhoodPlant)
    'ReadOnly Property NeighbourHoodPlantsArrayList() As ArrayList
    ReadOnly Property NeighbourhoodDiversityContrast() As INeighbourhoodDiversityContrast
    Sub SortSpatially()
End Interface

Public Interface INeighbourhoodDiversityContrast
    ReadOnly Property CenterPlant() As IPlant
    ReadOnly Property MeanTaxonomicContrastForNeighbourHood() As Double
End Interface


Public Interface IPlant
    ReadOnly Property GroupingInteger() As Integer
    ReadOnly Property UniqueKey() As String
    Property ShortId() As Integer
    Property LocationCurrent() As ISpatialPlantMapLocation
    ReadOnly Property LocationOriginal() As ISpatialPlantMapLocation
    ReadOnly Property TaxonomicSpecies() As ITaxonomicSpecies
    ReadOnly Property CanBeOriginPlantForCircles() As Boolean
    ReadOnly Property CanBeRandomized() As Boolean
End Interface


Public Interface IPlantList
    ReadOnly Property Count() As Integer
    ReadOnly Property PlantByIndexBaseOne(ByVal Index As Integer) As IPlant
    ReadOnly Property PlantByUniqueKey(ByVal UniqueKey As String) As IPlant
    Sub AddPlant(ByVal GroupingInteger As Integer, ByVal UniqueKey As String, ByVal ShortId As Integer, _
                    ByVal XCoordinate As Double, ByVal YCoordinate As Double, ByVal Species As ITaxonomicSpecies, ByVal CanBeOriginPlantForCircles As Boolean, ByVal CanBeRandomized As Boolean)
    Sub AddClonedPlant(ByVal Plant As IPlant)
    Sub AddPlantList(ByVal PlantList As IPlantList)
    Sub CalculateAndCacheAllSpatialDistancesAndShortIds()
    ReadOnly Property MaximumHorizontalOrVerticalSpatialSeparation() As Double
    Function TaxonomicDistanceBetweenPlants(ByVal FirstPlant As IPlant, ByVal SecondPlant As IPlant) As Single
    Function SpatialDistanceBetweenPlants(ByVal FirstPlant As IPlant, ByVal SecondPlant As IPlant) As Double
    Function CreateAnalysis() As IPlantListAnalysis
End Interface


Public Interface IPlantListAnalysis
    Function CalculateSpatialCircleOrCrownBasedTaxonomicContrast(ByVal InnerCircleRadius As Double, ByVal OuterCircleRadius As Double) As IPlantListTaxonomicContrast
    Function CalculateSpatialCircleWithNearestNeighboursBasedTaxonomicContrast(ByVal NumberOfNeighbourLower As Integer, ByVal NumberOfNeighbourHigher As Integer) As IPlantListTaxonomicContrast
End Interface

Public Interface IPlantListTaxonomicContrast
    Property TaxonomicContrast() As Double
    ReadOnly Property NeighbourhoodDiversityContrastList() As List(Of INeighbourhoodDiversityContrast)
End Interface


' Many list filters collected together
' item unique keys in different list filters do not need to match the order
Public Interface IListFilterCollection
    ReadOnly Property Count() As Integer
    ReadOnly Property ListFilterByIndexBaseOne(ByVal Index As Integer) As IListFilter
    ReadOnly Property ListFilterByName(ByVal Name As String) As IListFilter
    Function AddListFilter(ByVal Name As String) As IListFilter

End Interface

Public Interface ISpatialPlantMapLocation
    ReadOnly Property Index() As Integer
    ReadOnly Property xCoordinate() As Double
    ReadOnly Property yCoordinate() As Double
    Function GetDistanceFrom(ByVal AnotherLocation As ISpatialPlantMapLocation) As Double
End Interface


Public Interface ISpeciesAbundance
    ReadOnly Property UniqueKey() As String
    ReadOnly Property Abundance() As Double
    ReadOnly Property TaxonomicSpecies() As ITaxonomicSpecies
End Interface

' new list can always be created by filtering based on list filters
' only for non-spatial mode
Public Interface ISpeciesAbundanceList
    ReadOnly Property CountOfSpecies() As Integer
    ReadOnly Property SpeciesByIndexBaseOne(ByVal Index As Integer) As ISpeciesAbundance
    ReadOnly Property TaxonomicDistanceProvider() As ITaxonomicDistanceProvider
    Function NewSpeciesListByListFilter(ByVal ListFilter As IListFilter) As ISpeciesAbundanceList
    ReadOnly Property SpeciesListAnalysis() As ISpeciesListAnalysis
End Interface

Public Interface ISpeciesListAnalysis
    Function CalculateGenericNonSpatialTaxonomicDiversity() As Double
End Interface


Public Interface IStudy
    ReadOnly Property TaxonomicTree() As ITaxonomicTree
    Function CreateBaseSpeciesAbundanceList(Optional ByVal Abundances As IAbundanceCollection = Nothing) As ISpeciesAbundanceList
End Interface

Public Interface IStudyNonSpatial
    Inherits IStudy
    ReadOnly Property Abundances() As IAbundanceCollection
    ReadOnly Property SampledPlots() As IListFilterCollection
End Interface

Public Interface IStudySpatial
    Inherits IStudy
    ReadOnly Property PlantList() As IPlantList
    Function NewPlantListByFullCoordinatePermutation() As IPlantList
    Function NewPlantListByDistanceLimitedCoordinatePermutation(ByVal DistanceLimit As Double) As IPlantList
    Function NewPlantListByFullCoordinatePermutationPerGroup() As IPlantList
End Interface

Public Interface ITaxonomicSpecies
    ReadOnly Property UniqueKey() As String
    ReadOnly Property DisplayColour() As System.Drawing.Color
    ReadOnly Property Name() As String
End Interface


Public Interface ITaxonomicSpeciesCollection
    ReadOnly Property Count() As Integer
    ReadOnly Property TaxonomicSpeciesByIndexBaseOne(ByVal Index As Integer) As ITaxonomicSpecies
    ReadOnly Property TaxonomicSpeciesByUniqueKey(ByVal NodeUniqueKey As String) As ITaxonomicSpecies
End Interface

Public Interface ITaxonomicDistanceProvider
    Function TaxonomicDistanceBetweenSpecies(ByVal FirstSpecies As ITaxonomicSpecies, ByVal SecondSpecies As ITaxonomicSpecies) As Single
    ReadOnly Property AllSpecies() As ITaxonomicSpeciesCollection
End Interface

Public Interface ITaxonomicTree
    Inherits ITaxonomicDistanceProvider
    ReadOnly Property RootNode() As ITaxonomicTreeNode
    Function CreateOverrideDistanceLookupTable() As ITaxonomicDistanceLookupTable
    Function LogicalDistanceBetweenNodes(ByVal FirstNode As ITaxonomicTreeNode, ByVal SecondNode As ITaxonomicTreeNode) As Integer
    Function TaxonomicDistanceBetweenNodes(ByVal FirstNode As ITaxonomicTreeNode, ByVal SecondNode As ITaxonomicTreeNode) As Single
End Interface

Public Interface ITaxonomicDistanceLookupTable
    Sub SetInterSpeciesDistance(ByVal SpeciesOneName As String, ByVal SpeciesTwoName As String, ByVal Distance As Single)
End Interface

Public Interface ITaxonomicTreeNode
    ReadOnly Property UniqueKey() As String
    ReadOnly Property Name() As String
    ReadOnly Property DepthFromRootNode() As Integer
    ReadOnly Property ParentNode() As ITaxonomicTreeNode
    ReadOnly Property ChildNodeCount() As Integer
    ReadOnly Property ChildNodeItemByIndexBaseOne(ByVal Index As Integer) As ITaxonomicTreeNode
    ReadOnly Property DoesChildExist(ByVal UniqueKey As String) As Boolean
    ReadOnly Property ChildNodeItemByKey(ByVal UniqueKey As String) As ITaxonomicTreeNode
    Function AddChildNode(ByVal UniqueKey As String, ByVal Name As String) As ITaxonomicTreeNode
End Interface




